import {
    WebSocketGateway,
    WebSocketServer,
    SubscribeMessage,
    MessageBody,
    OnGatewayConnection,
    OnGatewayDisconnect,
  } from '@nestjs/websockets';
  
  @WebSocketGateway()
  export class WsGateway
    implements OnGatewayConnection, OnGatewayDisconnect
  {
    handleDisconnect(client: any) {
      console.log('close');
    }
    handleConnection(client: any, ...args: any[]) {
      console.log('incomin');
    }
  
    @SubscribeMessage('message')
    handleMessage(@MessageBody() data: string): string {
      console.log('Received message from client:', data);
      // 会接收到web的send方法里面的data数据
      return 'Hello from server';
    }
  }
 